package LeetCode.month02.day38;

public class No125 {
    public boolean isPalindrome(String s) {
        char[] chars = s.toCharArray();
        int n = chars.length;
        int left = 0,right= n-1;
        while(left<right){
            if(!Character.isLetter(chars[left])&&!Character.isDigit(chars[left])){
                left++;continue;
            }
            if(!Character.isLetter(chars[right])&&!Character.isDigit(chars[right])){
                right--;continue;
            }
            if(Character.toLowerCase(chars[left])!=Character.toLowerCase(chars[right])) return false;
            right--;
            left++;
        }
        return true;
    }
}
